﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint.Utilities;

namespace UserLimitedGroupSelection.Code
{
    public class UserLimitedGroupSelectionPrincipalInfoComparer : IEqualityComparer<SPPrincipalInfo>
    {
        /// <summary>
        /// Equalses the specified x.
        /// </summary>
        /// <param name="x">The x.</param>
        /// <param name="y">The y.</param>
        /// <returns></returns>
        public bool Equals(SPPrincipalInfo x, SPPrincipalInfo y)
        {
            return x.LoginName.Equals(y.LoginName, StringComparison.InvariantCultureIgnoreCase);
        }

        /// <summary>
        /// Returns a hash code for this instance.
        /// </summary>
        /// <param name="obj">The obj.</param>
        /// <returns>
        /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. 
        /// </returns>
        public int GetHashCode(SPPrincipalInfo obj)
        {
            return obj.LoginName.GetHashCode();
        }
    }
}
